﻿Public Class F21_Them_Phieu_Chi

    Private Sub btnthoatpt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnthoatpt.Click
        Me.Close()
    End Sub

    Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
        Dim f As New F11_Loai_Chi
        f.ShowDialog()
    End Sub

    Private Sub F21_Them_Phieu_Chi_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        cbxloaithunhappt.DataSource = XL_LoaiChi.LayDS()
        cbxloaithunhappt.DisplayMember = "Loai"
        cbxloaithunhappt.ValueMember = "ID"

        cbxnguoitao.DataSource = XL_NguoiDung.LayDS()
        cbxnguoitao.DisplayMember = "HoTen"
        cbxnguoitao.ValueMember = "ID"

        cbxnguoithu.DataSource = XL_NguoiDung.LayDS()
        cbxnguoithu.DisplayMember = "HoTen"
        cbxnguoithu.ValueMember = "ID"

        cbxtaikhoanpt.DataSource = XL_TaiKhoan.LayDS(Me.Tag)
        cbxtaikhoanpt.DisplayMember = "TenTK"
        cbxtaikhoanpt.ValueMember = "ID"
    End Sub

    Private Sub btnthempt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnthempt.Click
        Try
            Dim p As PhieuChi = New PhieuChi()
            p.Ngay = dtpngaychungtupt.Value.Date
            p.SoTien = Integer.Parse(txtsotienpt.Text)
            p.LoaiChi = cbxloaithunhappt.SelectedValue
            p.TaiKhoan = cbxtaikhoanpt.SelectedValue
            p.NguoiChi = cbxnguoithu.SelectedValue
            p.NguoiLap = cbxnguoitao.SelectedValue
            p.ChiTiet = rtbchitiet.Text
            XL_PhieuChi.Them(p)
            F22_No.tra = p.SoTien
        Catch ex As Exception
            MessageBox.Show("Kiểm tra thông tin!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning)
        End Try
    End Sub

    Private Sub btnxoapt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnxoapt.Click
        dtpngaychungtupt.Value = Now.Date
        txtsotienpt.Text = ""
        rtbchitiet.Text = ""
        cbxloaithunhappt.SelectedIndex = 0
        cbxnguoitao.SelectedIndex = 0
        cbxnguoithu.SelectedIndex = 0
        cbxtaikhoanpt.SelectedIndex = 0
    End Sub
End Class